#include "frameselfframejob.h"

#include <jobs/kdcstandardkprocessjob.h>
#include <KStandardDirs>

FrameSelfFrameJob::FrameSelfFrameJob( const QPixmap &aInput, QObject *aParent ) : KDCFrameJobInterface( aParent )
{
	aInput.save( pDir.name() + "/out.png", "png" );
	KDCStandardKProcessJob *job = new KDCStandardKProcessJob( this );
	job->setProgram( "convert" );
	job->addArgument( "out.png" );
	job->setWorkingDirectory( pDir.name() );
	job->addArgument( "\\( +clone -blur 0x9 +level 20%,100% \\)" );
	job->addArgument( "\\( +clone -gamma 0 -shade 20x20 -bordercolor white -border 20x20 \\)" );
	job->addArgument( "-composite" );
	job->addArgument( "\\( +clone -gamma 0 -shave 20x20 -bordercolor white -border 1x1 -bordercolor black -border 19x19 \\)" );
	job->addArgument( "-compose", "screen" );
	job->addArgument( "-composite" );
	job->setOutputFile( "out.png" );
	job->workAsShell( true );
	addSubjob( job );
}

FrameSelfFrameJob::~FrameSelfFrameJob()
{

}

QPixmap FrameSelfFrameJob::resultFrame() const
{
	return QPixmap( pDir.name() + "/out.png" );
}
